/*
 * @Author: szx
 * @Date: 2022-04-20 14:14:12
 * @LastEditTime: 2022-04-20 20:42:21
 * @Description:
 * @FilePath: \leetcode\300-399\388\388.js
 */
/**
 * @param {string} input
 * @return {number}
 */
var lengthLongestPath = function (input) {
    let res = 0,
        st = [];
    const arr = input.split('\n').map((a) => a.split('\t'));
    arr.forEach((a) => {
        while (a.length <= st.length) st.pop();
        const word = a[a.length - 1];
        st.push(word);
        if (word.indexOf('.') >= 0) res = Math.max(res, st.join('/').length);
    });
    return res;
};
console.log(lengthLongestPath('dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext'));
